package com.zzyl.nursing.service.impl;

import java.util.Arrays;
import java.util.List;

import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.utils.DateUtils;
import com.zzyl.nursing.dto.CheckInApplyDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zzyl.nursing.mapper.CheckInConfigMapper;
import com.zzyl.nursing.domain.CheckInConfig;
import com.zzyl.nursing.service.ICheckInConfigService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * 合同配置Service业务层处理
 * 
 * @author alexis
 * @date 2025-01-02
 */
@Service
public class CheckInConfigServiceImpl extends ServiceImpl<CheckInConfigMapper, CheckInConfig> implements ICheckInConfigService
{
    @Autowired
    private CheckInConfigMapper checkInConfigMapper;
    @Autowired
    private CheckInServiceImpl checkInService;

    /**
     * 查询合同配置
     * 
     * @param id 合同配置主键
     * @return 合同配置
     */
    @Override
    public CheckInConfig selectCheckInConfigById(Long id)
    {
        return checkInConfigMapper.selectById(id);
    }

    /**
     * 查询合同配置列表
     * 
     * @param checkInConfig 合同配置
     * @return 合同配置
     */
    @Override
    public List<CheckInConfig> selectCheckInConfigList(CheckInConfig checkInConfig)
    {
        return checkInConfigMapper.selectCheckInConfigList(checkInConfig);
    }

    /**
     * 新增合同配置
     * 
     * @param checkInConfig 合同配置
     * @return 结果
     */
    @Override
    public int insertCheckInConfig(CheckInConfig checkInConfig)
    {
        return checkInConfigMapper.insert(checkInConfig);
    }

    /**
     * 修改合同配置
     * 
     * @param checkInConfig 合同配置
     * @return 结果
     */
    @Override
    public int updateCheckInConfig(CheckInConfig checkInConfig)
    {
        return checkInConfigMapper.updateById(checkInConfig);
    }

    /**
     * 批量删除合同配置
     * 
     * @param ids 需要删除的合同配置主键
     * @return 结果
     */
    @Override
    public int deleteCheckInConfigByIds(Long[] ids)
    {
        return checkInConfigMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除合同配置信息
     * 
     * @param id 合同配置主键
     * @return 结果
     */
    @Override
    public int deleteCheckInConfigById(Long id)
    {
        return checkInConfigMapper.deleteById(id);
    }
    @PostMapping("/apply")
    public AjaxResult apply(@RequestBody CheckInApplyDto dto){
        checkInService.apply(dto);
        return AjaxResult.success();
    }
}
